package donajurema.model;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Read
{
	public static String String()
	{
	      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	      String s = null;
	      try 
	      {
	         s = br.readLine();
	      } 
	      catch (IOException ioe) 
	      {
	         System.out.println("IO error trying to read input!");
	         s = null;
	      }
	      return s;
	}
	
	public static int Integer()
	{
	      String s = Read.String();
	      int i;
	      try
	      {
	    	  i = Integer.parseInt(s);
	      }catch (Exception e)
	      {
	    	  System.out.println("Error trying to read number!");
	    	  i = -1;
	      }
	      return i;
	}
	
    // Check String for invalid characters
    public static String clean(String s)
    {
        // Replace invalid characters with empty strings.
        //return Regex.Replace(strIn, @"[^\w\.@-_ ]", "");
    	String EMPTY_STRING = "";
    	String WHITE_SPACE = " ";
    	
    	s = s.trim();
    	if (s == null) 	{ s = "Invalid name specified by user";} 
    	if (s.equals(WHITE_SPACE))	{ s = "Invalid name specified by user";}
    	if (s.equals(EMPTY_STRING))	{ s = "Invalid name specified by user";}
    	//s = s.replaceAll("[\\$@#!;:~^[]}{()]", "");
    	return s;
    }
	
}
